package utils

import "golang.org/x/crypto/bcrypt"

// 密码加密
func EncryPwd(password string) string {
	pwd := []byte(password)
	hash, _ := bcrypt.GenerateFromPassword(pwd, bcrypt.MinCost)
	return string(hash)
}

// 密码验证
func CheckPwd(hashPwd string, plainPwd string) bool {
	byteHash := []byte(hashPwd)
	err := bcrypt.CompareHashAndPassword(byteHash, []byte(plainPwd))
	if err != nil {
		return false
	}
	return true
}
